package com.daxt.model.service.base.vo;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableField;
import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "操作日志", description = "操作日志")
@TableName("base_operation_log")
public class OperationLog implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@TableId(value = "id", type = IdType.AUTO)
	private Long id;
//	@ApiModelProperty(value = "日志 0登录日志 1操作日志", name = "otype")
	@ApiModelProperty(value = "日志 1登录日志 2操作日志", name = "otype")
	private String otype;
	@ApiModelProperty(value = "操作标题", name = "otitle")
	private String otitle;
	@ApiModelProperty(value = "操作内容", name = "ocontent")
	private String ocontent;
	@ApiModelProperty(value = "请求参数", name = "param")
	private String param;
	@ApiModelProperty(value = "操作人", name = "operationBy")
	private String operationBy;
	@ApiModelProperty(value = "ip地址", name = "ip")
	private String ip;
	@ApiModelProperty(value = "操作人单位", name = "operationDept")
	private String operationDept;
	@ApiModelProperty(value = "全宗id", name = "fondsId")
	private String fondsId;

	@ApiModelProperty(value = "全宗名称", name = "fondsName")
	@TableField(exist = false)
	private String fondsName;

	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ApiModelProperty(value = "创建时间", name = "createTime",example = "2019-09-09 00:00:00")
	private LocalDateTime createTime;



	public static OperationLog buildParam(String otype,String ocontent,String param,String operationBy,String ip,String operationDept,String fondsId){
		OperationLog entity=new OperationLog();
		entity.setOtype(otype);
		entity.setOcontent(ocontent);
		entity.setParam(param);
		entity.setOperationBy(operationBy);
		entity.setIp(ip);
		entity.setOperationDept(operationDept);
		entity.setCreateTime(LocalDateTime.now());
		entity.setFondsId(fondsId);

		return entity;

	}
}
